package boot.utils;

import boot.entity.Pet;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * @Author: zhiyu
 * @Date:17:21
 * @DESC:
 */
@Component
public class StringToPet implements Converter<String, Pet> {

    @Override
    public Pet convert(String source) {
//        System.out.println(source);
        Pet pet = null;
        if (source!=null&&source!=""&&source.contains("&")){
            String[] split = source.split("&");
            pet = new Pet(split[0],Integer.parseInt(split[1]));
        }
        return pet;
    }
}
